home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1999 January - Disc 2 / Macworld (1999-01) (Disk 2).dmg / Serious Demos / Symbolic Composer 4.2 / Environment / Projects / Questions & Answers / Q&A Programming Functions / How to find 2 last symbols 2? < prev    next >
Encoding:
Text File  |  1998-10-26  |  426 b   |  22 lines  |  [TEXT/ScoM]

  1. HOW TO FIND 2 LAST SYMBOLS2
  2.  
  3. >The question: how do I find the last 2 symbols in the zone? the last 3? or the
  4. >3 symbols prior to the last 2 symbols in a zone?
  5.  
  6. (subseq '(a b c d e) 0 1)
  7. --> (a)
  8.  
  9. (let ((list '(a b c d e)))
  10.   (subseq list 2 (length list)))
  11. --> (c d e)
  12.  
  13. (defun last-n (n l)
  14.   (let ((maxlen (length l)))
  15.     (subseq l (- maxlen n) maxlen)))
  16.  
  17. (last-n 3 '(a b c d e))
  18. --> (c d e)
  19.  
  20. (last-n 2 '(a b c d e))
  21. --> (d e)
  22.